function stdChannel() {
  let listeners = [];
  /**
   *
   * @param {*} actionType 等待的动作类型
   * @param {*} taker 等待之后执行处理函数 next
   */
  function on(actionType, listener) {
    listener.actionType = actionType; // ASYNC_ADD
    listener.cancel = () => {
      listeners = listeners.filter((item) => item !== listener);
    };
    listeners.push(listener);
  }
  // 触发，执行处理函数
  function trigger(action) {
    listeners.forEach((taker) => {
      if (taker.actionType === action.type) {
        taker.cancel();
        taker(action);
      }
    });
  }
  return { on, trigger };
}
export default stdChannel;
